terraform {
  backend "s3" {
    endpoint = "http://minio.deeproute.ai"
    bucket = "terraform"
    key = "dev-uat/services/lb-tcp"
    region = "main"
    skip_credentials_validation = true
    skip_metadata_api_check = true
    skip_region_validation = true
    force_path_style = true
  }
}

module "install_haproxy" {
  source = "git@code.deeproute.ai:deeproute/ops-terraform.git//ansible_provisioner?ref=module.v1.0.0"

  arguments = [
    "--user=devops",
    "-b",
    "-i hosts.yml"
  ]
  envs      = [
    "host=loadbalancer",
    "ansible_python_interpreter=/usr/bin/python3"
  ]
  playbook  = "../../../playbooks/projects/site-default-haproxy.yml"
  dry_run   = false
}

module "install_consul_template" {
  source = "git@code.deeproute.ai:deeproute/ops-terraform.git//ansible_provisioner?ref=module.v1.0.1"

  arguments = [
    "--user=devops",
    "-b",
    "-i hosts.yml"
  ]
  envs      = [
    "host=loadbalancer",
    "consul_server=dev-consul.deeproute.cn",
    "edge_node=10.9.9.65",
    "consul_server_port=30080",
    "ansible_python_interpreter=/usr/bin/python3"
  ]
  playbook  = "../../../playbooks/projects/site-lb-tcp.yml"
  dry_run   = false
}

module "install_keepalived" {
  source = "git@code.deeproute.ai:deeproute/ops-terraform.git//ansible_provisioner?ref=module.v1.0.0"

  arguments = [
    "--user=devops",
    "-b",
    "-i hosts.yml"
  ]
  envs      = [
    "host=loadbalancer",
    "interfac=ens3",
    "vip=10.9.9.102/24",
    "ansible_python_interpreter=/usr/bin/python3"
  ]
  playbook  = "../../../playbooks/projects/site-keepalived-to-haproxy.yml"
  dry_run   = false
}